package com.party.core.dao.read.member;

import com.party.common.annotation.DataAuthParam;
import com.party.common.paging.Page;
import com.party.core.dao.read.BaseReadDao;
import com.party.core.model.member.Member;
import com.party.core.model.member.MemberMgmtQuery;
import com.party.core.model.member.PartnerMember;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Repository;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * 机构会员
 * Created by wei.li
 *
 * @date 2017/9/20 0020
 * @time 11:55
 */

@Repository
public interface PartnerMemberReadDao extends BaseReadDao<PartnerMember> {

    /**
     * 统计机构会员
     * @param parameter 请求参数
     * @return 统计数
     */
    List<HashMap<String, Object>> countByDate(@Param(value = "parameter") HashMap<String, Object> parameter);

    /**
     * 统计机构会员
     * @param parameter 请求参数
     * @return 统计数
     */
    Integer count(@Param(value = "parameter") HashMap<String, Object> parameter);

    /**
     * 会员管理列表
     * @param input
     * @param partnerId
     * @param page
     * @return
     */
    @DataAuthParam(moduleType="MEMBERMGMT" ,field="partner_id",alias="a")
    List<Map<String, Object>> listByPartnerId(@Param(value = "input") MemberMgmtQuery input,
                                              @Param(value = "partnerId") String partnerId, Page page);

    /**
     * 会员管理列表
     * @param partnerId
     * @return
     */
    List<Map<String, Object>> listByPartnerId2(@Param(value = "partnerId") String partnerId);

    /**
     * 获取机构下的所有会员
     * @param partnerId
     * @return
     */
    List<Member> getMembersByPartnerId(@Param(value = "partnerId") String partnerId);

    Long getCount(PartnerMember partnerMember);

    Long getMemberCountByOrgIds(@Param("orgIds") List<String> orgIds);

    /***
    * 获取当前机构下公司地址不为空的会员
    * @Date 9:55 2019/10/24
    * @param partnerId
    * @return
    **/
    List<Map<String, Object>> getAllCompanyAddress(@Param(value = "orgIds") List<String> orgIds,@Param(value = "partnerId") String partnerId);

    List<Map<String, Object>> companyAddressListMobile(@Param(value = "partnerId") String partnerId, @Param("orgIds") List<String> orgIds);

    /***
    * 获取当前机构下现居地址不为空的会员
    * @Date 9:56 2019/10/24
    * @param partnerId
    * @return
    **/
    List<Map<String, Object>> getAllHomeAddress(@Param(value = "orgIds") List<String> orgIds,@Param(value = "partnerId") String partnerId);

    List<Map<String, Object>> homeAddressListMobile(@Param(value = "partnerId") String partnerId, @Param("orgIds") List<String> orgIds);

    /**
     * 获取用户的主分社
     *
     * @param memberId 用户id
     * @param partnerId   机构id
     * @return 主机构
     * @author yifeng
     * @date 17:39 2019/11/14
     **/
    PartnerMember getMainOrg(@Param(value = "memberId") String memberId, @Param(value = "partnerId")String partnerId);

    /***
    * 获取用户机构
    * @Date 9:22 2019/11/15
    * @param partnerMember
    * @return
    **/
    List<PartnerMember> getMemberPartners(PartnerMember partnerMember);

    /***
     * 获取用户机构_to
     * @Date 9:22 2019/11/15
     * @param param
     * @return
     **/
    List<PartnerMember> getMemberPartnersTo(@Param(value = "param")Map<String,Object> param);

    @DataAuthParam(moduleType="MEMBERMGMT" ,field="partner_id",alias="a")
    List<Map<String, Object>> listByPartnerId3(@Param(value = "input") MemberMgmtQuery input,
                                               @Param(value = "partnerId") String partnerId, Page page);

    List<Map<String, Object>> listMembers(@Param(value = "input") MemberMgmtQuery input, Page page);

    Integer cAnalysisGetMemberCount(@Param("partnerIds")List<String> partnerIds,@Param("params")Map<String,Object> params);

    Integer getMemberRecommendCount(@Param("partnerIds")List<String> partnerIds,@Param("params")Map<String,Object> params);

    List<PartnerMember> getAllXzgsMember(@Param("params")Map<String, Object> params);
}
